package com.kkd.cloudxipet.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.kkd.cloudxipet.R;

import java.util.List;

/**
 * @author 14587
 * @date 2021/5/17 22:41
 */
public class MenuAdapter extends ArrayAdapter<String>{
    public static final String MENU_PERSONAL_CENTER = "个人中心";
    public static final String MENU_CONFIGURATION = "设置";
    public static final String MENU_HISTORY = "历史记录";
    public static final String MENU_COLLECT = "收藏";

    //background
    private int resourceId;
    public MenuAdapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
        super(context, resource, objects);
        this.resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        String item = getItem(position);
        ListView view = (ListView)LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        TextView menuText = (TextView)view.findViewById(R.id.menu_text);
        //ImageView menuBack = (ImageView) view.findViewById(R.id.menu_back);
        menuText.setText(item);
        //menuBack.setImageResource(resourceId);
        return view;
    }
}
